<template>
	<view>
		<view class="content">
			<u-navbar :fixed="false" title="报工" :autoBack="true" :safeAreaInsetTop="true" leftIconColor="#fff">
			</u-navbar>

			<view class="content_main"
				:style="{ opacity: BtnShow ? 1 : 0,overflow: formColumnOrRow == 'row' ? 'hidden' : 'auto' }">

				<!-- 悬浮按钮 -->
				<!-- <m-drag-button :style="{ opacity: BtnShow ? 1 : 0, }" v-show="!formData.Approve" :isDock="true"
					:existTabBar="true" :initialBottom="80"
					@btnClick="openBaseScreen(FCJType == 2 ? '工单号': '派工单号','scan')">
					<template #BtnContent>
						<u-icon name="scan" color="#fff" size="54rpx"></u-icon>
					</template>
				</m-drag-button> -->
				<m-drag-button :style="{ opacity: BtnShow ? 1 : 0, }" v-show="!formData.Approve" :isDock="true"
					:existTabBar="true" :initialBottom="80" @btnClick="OpenScanBtn">
					<template #BtnContent>
						<u-icon name="scan" color="#fff" size="54rpx"></u-icon>
					</template>
				</m-drag-button>

				<u--form labelPosition="left" :model="formData" :rules="rules" ref="uForm" labelWidth="100px"
					:labelStyle="{'font-size':'14px'}" style="height: 100%;">


					<view :style="{display:'flex',flexDirection:formColumnOrRow}" style="height: 100%;">

						<view :class="{'flex-auto':formColumnOrRow == 'row' }">
							<u-form-item label="报工单号" disabled borderBottom leftIcon="file-text"
								:leftIconStyle="{'font-size':'20px'}">
								<u--input v-model="formData.BGBillNo" readonly placeholder="自动生成"
									border="none"></u--input>
							</u-form-item>

							<u-form-item v-if="FCJType == 1" label="派工单号" prop="BillNO" borderBottom
								leftIcon="file-text" required :leftIconStyle="{'font-size':'20px'}">

								<view @click="openBaseScreen('派工单号','radio')">
									<u--input v-model="formData.BillNO" readonly placeholder="请扫码或选择"
										border="none"></u--input>
								</view>

								<view slot="right" class="x-f">
									<u-icon name="arrow-right" color="#999"></u-icon>
									<!-- <u-icon name="scan" size="28" color="#999"></u-icon> -->
									<u-icon name="scan" @click="OpenScanBtn" size="28" color="#999"></u-icon>
								</view>
							</u-form-item>

							<u-form-item v-if="FCJType == 2" label="工单号" prop="WoBillNO" borderBottom
								leftIcon="file-text" required :leftIconStyle="{'font-size':'20px'}">
								<view @click="openBaseScreen('工单号','radio')">

									<u--input v-model="formData.WoBillNO" readonly placeholder="请扫码或选择"
										border="none"></u--input>
								</view>

								<view slot="right" class="x-f">
									<u-icon name="arrow-right" color="#999"></u-icon>
									<!-- <u-icon name="scan" size="28" color="#999"></u-icon> -->
									<u-icon name="scan" @click.stop="OpenScanBtn" size="28" color="#999"></u-icon>
								</view>
							</u-form-item>

							<u-form-item label="报工类型" prop="JobDocTypeName"
								:disabled="!$utils.isEmpty(formData.BGBillNo)" borderBottom leftIcon="file-text"
								required @click="openBaseScreen('报工类型','radio')" :leftIconStyle="{'font-size':'20px'}">
								<u--input v-model="formData.JobDocTypeName" readonly placeholder="请选择"
									border="none"></u--input>

								<view slot="right" class="x-f">
									<u-icon name="arrow-right" color="#999"></u-icon>
								</view>
							</u-form-item>

							<!-- <u-form-item v-if="FCJType == 1" label="工单号" borderBottom leftIcon="order" disabled
								:leftIconStyle="{'font-size':'20px'}">
								<u--input v-model="formData.WoBillNO" readonly border="none"></u--input>
							</u-form-item> -->

							<u-form-item label="销售单号" borderBottom leftIcon="order" disabled
								:leftIconStyle="{'font-size':'20px'}">
								<u--input v-model="formData.SoBillNO" readonly border="none"></u--input>
							</u-form-item>

							<u-form-item label="产品信息" borderBottom leftIcon="order" disabled
								:leftIconStyle="{'font-size':'20px'}">
								<u--input v-model="formData.ProductCode" readonly border="none"></u--input>
							</u-form-item>

							<u-form-item label="生产车间" prop="FWorkshopName" borderBottom leftIcon="share" required
								@click="openBaseScreen('生产车间','radio')" :leftIconStyle="{'font-size':'20px'}">
								<u--input v-model="formData.FWorkshopName" readonly placeholder="请选择"
									border="none"></u--input>

								<view slot="right" class="x-f">
									<u-icon name="arrow-right" color="#999"></u-icon>
								</view>
							</u-form-item>

							<u-form-item label="工序名称" prop="ProcedureName" leftIcon="share" required
								@click="openBaseScreen('工序','radio')" :leftIconStyle="{'font-size':'20px'}">
								<u--input v-model="formData.ProcedureName" readonly placeholder="请选择"
									border="none"></u--input>

								<view slot="right" class="x-f">
									<u-icon name="arrow-right" color="#999"></u-icon>
								</view>


							</u-form-item>

							<view class="x-f">
								<u-form-item label="派工数" prop="FPlanQty" leftIcon="share" disabled style="flex: 1;"
									:leftIconStyle="{'font-size':'20px'}">
									<u--input v-model="formData.FPlanQty" readonly border="none"></u--input>
								</u-form-item>


								<u-form-item label="可报工数" prop="ReportQty" leftIcon="share" disabled style="flex: 1;"
									:leftIconStyle="{'font-size':'20px'}">
									<u--input v-model="formData.ReportQty" readonly border="none"></u--input>
								</u-form-item>
							</view>

							<!-- <view style="padding: 0 6px 0 16px;">
								<u-line></u-line>
							</view> -->

							<!-- <view class="x-f" style="background-color: #fff;"> -->
							<u-form-item label="计时计件" prop="PieceTimeName" leftIcon="share" required style="flex: 1;"
								@click="openBaseScreen('计时计件','radio')" :leftIconStyle="{'font-size':'20px'}">
								<u--input v-model="formData.PieceTimeName" readonly placeholder="请选择"
									border="none"></u--input>

								<view slot="right" class="x-f">
									<u-icon name="arrow-right" color="#999"></u-icon>
								</view>
							</u-form-item>

							<u-form-item label="作业员" prop="EmplName" leftIcon="share" required style="flex: 1;"
								@click="openBaseScreen('作业员','check')" :leftIconStyle="{'font-size':'20px'}">
								<u--input v-model="formData.EmplName" readonly placeholder="请选择"
									border="none"></u--input>

								<view slot="right" class="x-f">
									<u-icon name="arrow-right" color="#999"></u-icon>
								</view>
							</u-form-item>
							<!-- </view> -->

							<view style="padding: 0 6px 0 16px;">
								<u-line></u-line>
							</view>

							<u-form-item label="班次" prop="ShiftName" leftIcon="share" borderBottom required
								@click="openBaseScreen('班次','radio')" :leftIconStyle="{'font-size':'20px'}">
								<u--input v-model="formData.ShiftName" readonly placeholder="请选择"
									border="none"></u--input>

								<view slot="right" class="x-f">
									<u-icon name="arrow-right" color="#999"></u-icon>
								</view>
							</u-form-item>

						</view>

						<view v-if="formColumnOrRow == 'row'" style="background-color: #f9f9f9;width: 10px;"></view>

						<view :class="{'flex-auto':formColumnOrRow == 'row' }">
							<u-form-item label="合格数" borderBottom leftIcon="share"
								:leftIconStyle="{'font-size':'20px'}">
								<u--input v-model="formData.FDailyQtt" type="number" placeholder="请输入合格数"
									border="none"></u--input>
							</u-form-item>

							<view class="x-f">
								<u-form-item label="工废数" leftIcon="share" style="flex: 1;"
									:leftIconStyle="{'font-size':'20px'}">
									<u--input v-model="formData.IndustrialWaste" @input="InputNums" type="number"
										border="none"></u--input>
								</u-form-item>

								<u-form-item label="料废数" leftIcon="share" style="flex: 1;"
									:leftIconStyle="{'font-size':'20px'}">
									<u--input v-model="formData.MaterialWaste" @input="InputNums" type="number"
										border="none"></u--input>
								</u-form-item>
							</view>

							<view style="padding: 0 6px 0 16px;">
								<u-line></u-line>
							</view>

							<!-- <u-form-item label="报废数" prop="FNgQty" disabled leftIcon="share"
							:leftIconStyle="{'font-size':'20px'}">
							<u--input v-model="formData.FNgQty" type="number" readonly placeholder="请输入报废数"
								border="none"></u--input>
						</u-form-item> -->


							<u-form-item label="报工时长" :prop="formData.PieceTime == 1 ? 'ManHour' : ''" leftIcon="share"
								borderBottom :required="formData.PieceTime != 0" style="margin-top: 10px;">
								<view class="x-f" style="width: 100%;">
									<view class="x-f" style="flex: 1;padding: 0 10px;">
										<u--input style="flex: 1;" type="number" v-model="formData.Hour"
											inputAlign="center" @input="ChangeDate" border="none"
											@blur="BlurDateIpt('hour')"></u--input>
										<text>小时</text>

										<u--input style="flex: 1;" type="number" v-model="formData.Minute"
											inputAlign="center" @input="ChangeDate" border="none"
											@blur="BlurDateIpt('minute')"></u--input>
										<text>分钟</text>
									</view>

									<view class="x-f" @click="OpenChoiceDate"
										style="height: 100%;min-width: 30px;justify-content: center;">
										<u-icon name="arrow-right" color="#999" size="20"></u-icon>
									</view>

								</view>
							</u-form-item>


							<!-- 起止时间 -->
							<u-form-item leftIcon="calendar" :leftIconStyle="{'font-size':'20px'}"
								:required="formData.PieceTime != 0">
								<view class="ChoiceTimesBox">

									<view class="TimeBox">

										<view class="StartTime timer" @click="ChoiceTime('start')">
											<text>开始时间</text>
											<text>{{formData.StartTime }}</text>
										</view>

										<view class="Icon">
											<u-icon name="minus" size="30"></u-icon>
										</view>

										<view class="EndTime timer" @click="ChoiceTime('end')">
											<text>结束时间</text>
											<text>{{formData.EndTime}}</text>
										</view>
									</view>
								</view>
							</u-form-item>

							<u-form-item label="模具编号" leftIcon="coupon" @click="openBaseScreen('模具编号','radio')"
								:leftIconStyle="{'font-size':'20px'}" style="margin-top: 10px;">
								<u--input v-model="formData.MoludCode" readonly placeholder="请选择"
									border="none"></u--input>

								<view slot="right" class="x-f">
									<u-icon name="arrow-right" color="#999"></u-icon>
								</view>
							</u-form-item>


							<u-form-item label="设备/产线" leftIcon="share" style="flex: 1;"
								@click="openBaseScreen('设备','radio')" :leftIconStyle="{'font-size':'20px'}">
								<u--input v-model="formData.EquipmentName" readonly placeholder="请选择"
									border="none"></u--input>

								<view slot="right" class="x-f">
									<u-icon name="arrow-right" color="#999"></u-icon>
								</view>
							</u-form-item>

							<u-form-item label="备注" leftIcon="attach" :leftIconStyle="{'font-size':'20px'}"
								class="TopOption" style="margin-top: 10px;">
								<view class="" style="padding: 10px 20px 0;width: 100%;">
									<u--textarea v-model="formData.FRemarks" placeholder="请输入内容" count
										maxlength="150"></u--textarea>
								</view>
							</u-form-item>

							<!-- <u-form-item class="PriceItem TopOption" label="工资绩效" leftIcon="attach"
							:leftIconStyle="{'font-size':'26px'}" style="margin-top: 10px;">
						</u-form-item>
						<u-form-item label="工资单价" leftIcon="attach" borderBottom :leftIconStyle="{'font-size':'20px'}"
							style="padding-top: 4px;padding-bottom: 4px;">
							<view>0元</view>
						</u-form-item>
						<u-form-item label="预计工资" leftIcon="attach" :leftIconStyle="{'font-size':'20px'}"
							style="padding-top: 4px;padding-bottom: 4px;">
							<view>0元</view>
						</u-form-item> -->


						</view>

					</view>
				</u--form>
			</view>


			<view class="BottomBox safe_buttom" :style="$utils.disposeSafeBottomFun()">
				<button :disabled="!enabledSubmitBtn" v-if="isEdit && formData.FDailyOutputDeID"
					class="content_bottom_primary_plainBtn CommonBtnSize" @click="WorkInit">继续报工</button>

				<button :disabled="!enabledSubmitBtn" v-if="!formData.FDailyOutputDeID"
					class="content_bottom_primary_Btn" style="width: 90%;margin: 0 auto !important;"
					@click="SubmitBtn">提交</button>

				<button :disabled="!enabledSubmitBtn"
					v-if="formData.FDailyOutputDeID && !formData.Approve && ApproveBack('修改')"
					class="content_bottom_primary_Btn CommonBtnSize" @click="EditBtn('Edit')">修改</button>

				<!-- <button v-if="formData.FDailyOutputDeID && hasApprove" class="content_bottom_primary_Btn moreBtn"
					@click="EditBtn('Audit')">{{formData.Approve ? '撤审':'审核'}}</button> -->
				<!-- 当 formData.Approve 为 true 时，显示“撤审”按钮 -->
				<button :disabled="!enabledSubmitBtn"
					v-if="formData.FDailyOutputDeID && hasApprove && formData.Approve && ApproveBack('撤审')"
					class="content_bottom_primary_Btn CommonBtnSize" @click="EditBtn('Audit')">
					撤审
				</button>

				<!-- 当 formData.Approve 为 false 时，显示“审核”按钮 -->
				<button :disabled="!enabledSubmitBtn"
					v-if="formData.FDailyOutputDeID && hasApprove && !formData.Approve && ApproveBack('审核')"
					class="content_bottom_primary_Btn CommonBtnSize" @click="EditBtn('Audit')">
					审核
				</button>
			</view>

		</view>


		<!-- 操作菜单 -->
		<u-action-sheet :safeAreaInsetBottom="true" :closeOnClickOverlay="true" :closeOnClickAction="true"
			@close="closeContinuePopup" :actions="ContinueData" @select="selectClick" :show="ShowContinuePopup"
			ShowText="text" cancelText="取消"></u-action-sheet>

		<!-- 扫设备带出可报工工序 -->
		<u-popup :show="showPopupByDevice" :round="20" mode="center" :closeOnClickOverlay="false"
			@close="closeDevicePopup" style="background-color: transparent;">
			<view class="f-dc"
				style="width: 80vw;height: 60vh;background-color: #f1f1f1;border-radius: 20rpx;overflow: hidden;">
				<z-paging v-if="showPopupByDevice" ref="paging" :fixed="false" v-model="ScanByDeviceList"
					@query="getMainInfoByDevice">
					<!-- 需要固定在顶部不滚动的view放在slot="top"的view中，如果需要跟着滚动，则不要设置slot="top" -->
					<!-- 注意！此处的z-tabs为独立的组件，可替换为第三方的tabs，若需要使用z-tabs，请在插件市场搜索z-tabs并引入，否则会报插件找不到的错误 -->
					<template #top>
						<u-navbar :fixed="false" :title="'设备-工序' + '(' + ScanByDeviceList.length + ')'"
							:titleStyle="{'font-size':'16px'}" :autoBack="false" leftIcon=" " :safeAreaInsetTop="false">
							<view class="u-nav-slot" slot="right">
								<uni-icons color="#fff" type="close" size="30" @click="closeDevicePopup"></uni-icons>
							</view>
						</u-navbar>
					</template>

					<view class="content_main_CardBox" v-for="(item,index) in ScanByDeviceList" :key="index"
						@click="ChoiceDeviceToProcedure(index)" style="margin-bottom: 10rpx;">

						<view style="position: absolute;right: 20rpx;top: 20rpx;">
							<view style="position: relative;">
								<checkbox class="CheckBox" :checked="item.checked" activeBackgroundColor="#51d0d0"
									activeBorderColor="#51d0d0">
								</checkbox>

								<view
									style="width: 100%;height: 100%;background-color: transparent;position: absolute;z-index: 9;left: 0;top: 0;">
								</view>

							</view>
						</view>

						<m-field valueFontSize="24rpx" labelFontSize="24rpx" labelWidth="100rpx" paddings="8rpx"
							:borderBottom="false" label="工单编号" :value="item.WoBillNO">
						</m-field>

						<m-field valueFontSize="24rpx" labelFontSize="24rpx" labelWidth="100rpx" paddings="8rpx"
							:borderBottom="false" label="派工单号" :value="item.BillNO">
						</m-field>

						<m-field valueFontSize="24rpx" labelFontSize="24rpx" labelWidth="100rpx" paddings="8rpx"
							:borderBottom="false" label="产品" :value="item.ProductName || '-'">
						</m-field>

						<m-field valueFontSize="24rpx" labelFontSize="24rpx" labelWidth="100rpx" paddings="8rpx"
							:borderBottom="false" label="规格" :value="item.ProductSpec || '-'">
						</m-field>

						<m-field valueFontSize="24rpx" labelFontSize="24rpx" labelWidth="100rpx" paddings="8rpx"
							:borderBottom="false" label="工序" :value="item.ProcedureName">
						</m-field>

						<m-field valueFontSize="24rpx" labelFontSize="24rpx" labelWidth="100rpx" paddings="8rpx"
							:borderBottom="false" label="设备" :value="item.EquipmentName">
						</m-field>

						<m-field valueFontSize="24rpx" labelFontSize="24rpx" labelWidth="100rpx" paddings="8rpx"
							:borderBottom="false" label="可报数量" :value="item.ReportQty">
						</m-field>
					</view>

				</z-paging>

				<!-- <u-navbar :fixed="false" :title="'设备-工序' + '(' + ScanByDeviceList.length + ')'"
					:titleStyle="{'font-size':'16px'}" :autoBack="false" leftIcon=" " :safeAreaInsetTop="false">
					<view class="u-nav-slot" slot="right">
						<uni-icons color="#fff" type="close" size="30" @click="closeDevicePopup"></uni-icons>
					</view>
				</u-navbar>

				<view style="padding: 10rpx;overflow: auto;flex: 1;">

					<view class="content_main_CardBox" v-for="(item,index) in ScanByDeviceList" :key="item.JobPROCID"
						@click="ChoiceDeviceToProcedure(index)" style="margin-bottom: 10rpx;">

						<view style="position: absolute;right: 20rpx;top: 20rpx;">
							<view style="position: relative;">
								<checkbox class="CheckBox" :checked="item.checked" activeBackgroundColor="#51d0d0"
									activeBorderColor="#51d0d0">
								</checkbox>

								<view
									style="width: 100%;height: 100%;background-color: transparent;position: absolute;z-index: 9;left: 0;top: 0;">
								</view>

							</view>
						</view>

						<m-field valueFontSize="24rpx" labelFontSize="24rpx" labelWidth="100rpx" paddings="8rpx"
							:borderBottom="false" label="工单编号" :value="item.WoBillNO">
						</m-field>

						<m-field valueFontSize="24rpx" labelFontSize="24rpx" labelWidth="100rpx" paddings="8rpx"
							:borderBottom="false" label="派工单号" :value="item.BillNO">
						</m-field>

						<m-field valueFontSize="24rpx" labelFontSize="24rpx" labelWidth="100rpx" paddings="8rpx"
							:borderBottom="false" label="产品" :value="item.ProductName || '-'">
						</m-field>

						<m-field valueFontSize="24rpx" labelFontSize="24rpx" labelWidth="100rpx" paddings="8rpx"
							:borderBottom="false" label="规格" :value="item.ProductSpec || '-'">
						</m-field>

						<m-field valueFontSize="24rpx" labelFontSize="24rpx" labelWidth="100rpx" paddings="8rpx"
							:borderBottom="false" label="工序" :value="item.ProcedureName">
						</m-field>

						<m-field valueFontSize="24rpx" labelFontSize="24rpx" labelWidth="100rpx" paddings="8rpx"
							:borderBottom="false" label="设备" :value="item.EquipmentName">
						</m-field>

						<m-field valueFontSize="24rpx" labelFontSize="24rpx" labelWidth="100rpx" paddings="8rpx"
							:borderBottom="false" label="可报数量" :value="item.ReportQty">
						</m-field>
					</view>
				</view> -->

				<view class="BottomBox x-f" style="padding-top: 6rpx;">
					<button style="width: 100%;border: none !important;border-radius: initial !important;"
						class="content_bottom_primary_plainBtn" @click="closeDevicePopup">取消</button>
					<button style="width: 100%;border-radius: initial !important;" class="content_bottom_primary_Btn"
						@click="ChoiceProcedure_Config">确认</button>
				</view>

			</view>
		</u-popup>

		<!-- 摄像头使用权限弹层组件 -->
		<m-permission ref="permissionDialog" title="相机/相册权限申请说明">
			于您使用该功能扫码，用于查询数据场景，你需要允许相机使用权限
		</m-permission>

		<!-- 报工时长时间选择器 -->
		<u-datetime-picker class="DateTimerPick" ref="datetimePickerBG" title="选择报工时长" :show="showTimePickerBG"
			v-model="DatetimeDataBG" mode="time" :closeOnClickOverlay="true" @close="ClosePickerBG"
			@cancel="ClosePickerBG" @confirm="ConfirmTimeBG" :formatter="formatter"></u-datetime-picker>

		<m-loading :text="loadingText" v-model="showMLoading" :showClose="false"
			maskBackgroundColor="rgba(0,0,0,0.3)"></m-loading>


		<!-- 起止时间选择器 -->
		<u-datetime-picker ref="datetimePicker" :title="PickerTitle" :show="showTimePicker" v-model="DatetimeData"
			mode="datetime" :closeOnClickOverlay="true" @close="ClosePicker" @cancel="ClosePicker"
			@confirm="ConfirmTime" :formatter="formatter"></u-datetime-picker>

		<m-pda-scancode v-if="$utils.isPda()" listenName="createWorkCode"
			:SetContent="{action:$store.state.systemConfig.sysDeviceInfo.broadcastAction,extra:$store.state.systemConfig.sysDeviceInfo.broadcastResult}"></m-pda-scancode>
	</view>
</template>

<script>
	import layerFun from '@/common/comFun/layerFun.js';
	var layer = layerFun;
	// 新建报工
	export default {
		data() {
			return {
				enabledSubmitBtn: false, // 控制按钮是否启用
				showMLoading: false, // 加载动画
				loadingText: "正在渲染",
				FCJType: 2, // 查询公司报工类型 1、派工 2、工单
				isEdit: false, // 是否是列表进来的
				hasApprove: false, // 是否有审核权限
				formData: {
					FDailyOutputDeID: null,
					QrCode: null,
					WoBillNO: null, // 工单号
					BillNO: null, // 派工单号

					JobDocTypeName: null, // 报工类型
					JobDocTypeID: null, // 报工类型ID

					FWorkshopName: null, // 车间
					FWorkshopID: null, // 车间ID

					ProcedureName: null, // 工序
					ProcedureID: null, // 工序ID

					WoPROCID: null, // 工单工序

					PieceTimeName: '', // 计时计件
					PieceTime: '', // 计时计件

					EmplName: null, // 作业员
					EmplID: null,

					FPlanQty: null, // 派工书
					WCQty: null, // 完成数
					ReportQty: null, // 可报工数
					FDailyQtt: null, // 填写合格数
					FNgQty: null, // 
					IndustrialWaste: null, // 工废数
					MaterialWaste: null, // 料废数

					EquipmentName: null, // 

					ShiftName: null, // 班次
					ShiftID: null,

					MoludName: null, // 模具
					MoludCode: null, // 模具
					MoludID: null,
					MoludTypeID: null,

					EquipmentName: '',
					EquipmentCode: null, // 设备/产线
					EquipmentID: null,

					Hour: 0, // 小时
					Minute: 0, // 分钟
					StartTime: null, // 开始时间
					EndTime: null, // 结束时间

					Approve: false, // 是否审核

					FRemarks: '',
				},
				rules: {
					'WoBillNO': { // 工单号
						type: 'string',
						required: true,
						message: '工单号不能为空',
						trigger: ['change']
					},
					'BillNO': { // 派工单号
						type: 'string',
						required: true,
						message: '派工单号不能为空',
						trigger: ['change']
					},
					'FWorkshopName': { // 生产车间
						type: 'string',
						required: true,
						message: '生产车间不能为空',
						trigger: ['change']
					},
					'ProcedureName': { // 工序
						type: 'string',
						required: true,
						message: '工序不能为空',
						trigger: ['change']
					},
					'PieceTimeName': { // 计时计件
						type: 'string',
						required: true,
						message: '计时计件不能为空',
						trigger: ['change']
					},
					'EmplName': { // 作业员
						type: 'string',
						required: true,
						message: '作业员不能为空',
						trigger: ['change']
					},
					'ShiftName': { // 班次
						type: 'string',
						required: true,
						message: '班次不能为空',
						trigger: ['change']
					},
					'ManHour': { // 报工时长
						type: 'string',
						required: true,
						message: '报工时长不能为空',
						trigger: ['change']
					},
				},

				PieceTimeNameData: [{
						PieceTimeName: '计件',
						PieceTime: 0
					},
					{
						PieceTimeName: '计时',
						PieceTime: 1
					}
				],

				showTimePickerBG: false, // 时间选择器弹层
				DatetimeDataBG: null, // 时间选择器时间


				DatetimeData: Number(new Date()), // 时间选择器时间
				showTimePicker: false, // 时间选择器弹层显示
				TimeType: '', // 区分时间 start - 开始 ， end - 结束
				PickerTitle: '', // 时间弹层标题
				BtnShow: false, // 按钮样式初始化有问题，等加载完再显示

				showPopupByDevice: false, // 扫设备码带出的工序弹层
				DeviceID: null, // 扫描的设备ID
				ScanByDeviceList: [], // 弹层列表数据
				SelectScanByDeviseIndex: null, // 点击的卡片数据索引

				BtnApprove: [], // 权限数组

				ShowContinuePopup: false, // 操作菜单
				ContinueData: [{
					text: '空白报工',
					id: 0
				}, {
					text: '连续报工',
					id: 1
				}],

				primaryType: false, // 左右布局
				formColumnOrRow: "column",

				UserWorkshopID: 0,

				FilterFormData: { // 主表多选字段数据存储
					EmplIDData: [],
					EmplIDDataJoin: '',
				},
			};
		},
		onLoad(option) {
			var that = this;

			let foundNode = null;
			// 获取页面按钮权限
			for (const module of this.$store.state.appConfigInfo.ModuleInfo_All) {
				if (module.TreeTypeName === '生产管理') {
					for (const node of module.Node) {
						if (node.APFunName === '新建报工') {
							foundNode = JSON.parse(JSON.stringify(node));
							break; // 找到后立即退出内层循环  
						}
					}
					if (foundNode) {
						break;
					}
				}
			}
			console.log(foundNode);


			const deviceInfo = uni.getSystemInfoSync();
			let sysDeviceInfo = {}; // 默认空对象避免判空异常

			try {
				const storedData = uni.getStorageSync('sysDeviceInfo');
				if (storedData) sysDeviceInfo = JSON.parse(storedData);
			} catch (error) {
				console.error('sysDeviceInfo 解析失败:', error);
			}

			const isWideScreen = deviceInfo.windowWidth >= 800;
			const type = sysDeviceInfo.scanDeviceType === 'GKJ' || isWideScreen ? 'row' : 'column';


			// console.log(type);
			this.formColumnOrRow = type;

			this.BtnApprove = foundNode['IconApprove'];

			that.FCJType = this.$store.getters.GetFCJType; // 查询公司报工类型


			if (!this.$utils.isEmpty(option)) { //回显

				if (option.Edit == 'isEdit') {
					that.isEdit = true;
				}

				this.formData.FDailyOutputDeID = option.FDailyOutputDeID;

				// 获取是否有审核权限
				// this.getXGD_GetWorkApprove();

				this.GetEchoData(option.FDailyOutputDeID);

			} else {
				this.InitFormData();

			}

			that.GetUserWorkshop();
		},
		computed: {},
		watch: {},
		mounted() {
			let that = this;
			setTimeout(() => {
				that.BtnShow = true;
			}, 300)


			if (that.$utils.isPda()) {

				uni.$on('createWorkCode', function(content) {
					that.$utils.showLoading('正在解码');
					that.getMainInfo(content)
				})
			}

			uni.$on('CreateWorks_Choice', function(ret) {
				if (ret.type == '工单号' || ret.type == '派工单号') {
					that.InitCreateFun();
					setTimeout(() => {
						ret.data['BillNO'] = ret.data['JobBillNO'];
						that.formData = Object.assign(that.formData, ret.data);

						console.log(ret.data)

						// 当前以选中工单号、派工单号，获取工序
						that.GetProcedureData();
						that.$refs.uForm.validate();
					}, 300)
				} else if (ret.type == '报工类型') {
					that.formData.JobDocTypeName = ret.data.TypeName;
					that.formData.JobDocTypeID = ret.data.JobDocTypeID;
				} else if (ret.type == '生产车间') {
					that.formData.FWorkshopName = ret.data.FWorkshopName;
					that.formData.FWorkshopID = ret.data.FWorkshopID;
				} else if (ret.type == '工序') {
					ret.data['FNgQty'] = null;

					ret.data['FDailyQtt'] = ret.data['ReportQty'];
					console.log(ret.data);

					that.formData = Object.assign(that.formData, ret.data);
				} else if (ret.type == '模具编号') {
					that.formData = Object.assign(that.formData, ret.data);
				} else if (ret.type == '设备') {
					that.formData = Object.assign(that.formData, ret.data);
				} else if (ret.type == '班次') {
					that.formData = Object.assign(that.formData, ret.data);
				} else if (ret.type == '作业员') {
					that.FilterFormData.EmplIDData = JSON.parse(JSON.stringify(ret.data));
					that.FilterFormData.EmplIDDataJoin = ret.data.map(item => item.EmplName).join(',');
					that.formData.EmplName = that.FilterFormData.EmplIDDataJoin;
					that.formData.EmplID = ret.data.map(item => item.EmplID).join(',');

					//that.formData = Object.assign(that.formData, ret.data);
				} else if (ret.type == '计时计件') {
					that.formData = Object.assign(that.formData, ret.data);
				}

				that.$refs.uForm.validate();

			});


			// 组件中监听队列完成
			this.$onQueueEvent('queueEmpty', () => {
				// 当所有事件加载完成后：
				// 开放按钮点击权限

				that.$utils.hideLoading();
				that.enabledSubmitBtn = true; // 解开按钮限制
				that.showMLoading = false;
				setTimeout(() => {
					that.loadingText = "正在渲染";
				}, 500);
			});

		},
		onUnload() {
			let that = this;
			uni.$off('CreateWorks_Choice')
			if (that.$utils.isPda()) {
				uni.$off('createWorkCode')
			}
			plus.screen.lockOrientation('portrait-primary');

		},
		methods: {
			InitFormData() {
				let that = this;
				let date = that.Request.dateFormat(new Date(), 'MM-dd  hh:mm');
				this.formData.StartTime = date;
				this.formData.EndTime = date;

				// 赋值默认计时计件数据
				that.formData = Object.assign(that.formData, this.PieceTimeNameData[0]);

				// 获取报工类型
				this.GetPGD_GetBGType();

				// 获取默认班次
				that.GetDroplist_Shift();

				this.getEmplInfo();
			},
			GetUserWorkshop() {
				let that = this;

				let UserID = that.$store.state.UserInfo.UserID;

				let sql = `select isnull(FWorkshopID,0) as FWorkshopID from SYS_User where UserID=${UserID}`;
				//console.log(sql);
				try {
					that.$requestByUrl("/SQLData/QuerySql", {
						sql: sql
					}, function(data) {
						if (data.ds.length && data.ds[0].hasOwnProperty("FWorkshopID")) {
							that.UserWorkshopID = data.ds[0].FWorkshopID;
						}
					});
				} catch (e) {
					console.log(e);
					that.UserWorkshopID = 0;
				}



			},
			getEmplInfo() {
				let that = this;

				let UserID = that.$store.state.UserInfo.UserID;

				let sql = `select isnull(a.EmplID,0) as EmplID,isnull(b.EmplName,'') as EmplName
							from SYS_User a
							left join Hr_Employee b on a.EmplID=b.EmplID
							where a.UserID=${UserID}`;
				//console.log(sql);
				try {
					that.$requestByUrl("/SQLData/QuerySql", {
						sql: sql
					}, function(data) {
						console.log(JSON.stringify(data))
						if (data.ds.length && data.ds[0].EmplID) {
							// that.formData.EmplID = data.ds[0].EmplID;
							// that.formData.EmplName = data.ds[0].EmplName;
							// console.log(that.formData.EmplID);
							// console.log(that.formData.EmplName);
							that.FilterFormData.EmplIDData = JSON.parse(JSON.stringify(data.ds));
							that.FilterFormData.EmplIDDataJoin = data.ds.map(item => item.EmplName).join(
								',');
							that.formData.EmplName = that.FilterFormData.EmplIDDataJoin;
							that.formData.EmplID = data.ds.map(item => item.EmplID).join(',');
						}
					});
				} catch (e) {
					console.log(e);
					that.formData.EmplID = null;
					that.formData.EmplName = null;
				}
			},
			revolveBtn() { // 点击旋转
				let that = this;


				if (this.formColumnOrRow == 'row') {
					this.formColumnOrRow = 'column'
				} else {
					this.formColumnOrRow = 'row'
				}
			},
			ApproveBack(str) {
				let that = this;
				console.log(that.BtnApprove);
				let Type = that.BtnApprove.some(item => {
					return item.MenuName == str
				})

				return Type;
			},
			InitCreateFun() { // 如果切换工单号或派工单号，将界面初始化
				let that = this;
				that.isEdit = false; // 将状态却换成非编辑状态
				that.hasApprove = false; // 关闭审核

				Object.keys(that.formData).forEach((key) => {
					if (!['EmplID', 'EmplName', 'PieceTime', 'PieceTimeName',
							'ShiftID', 'ShiftName', 'JobDocTypeName', 'JobDocTypeID'
						].includes(key)) {


						if (that.formData[key] == null) {
							that.formData[key] = null;
						} else if (Array.isArray(that.formData[key])) {
							that.formData[key] = [];
						} else if (typeof that.formData[key] === 'object') {
							that.formData[key] = {};
						} else {
							that.formData[key] = '';
						}
					}
				});

			},
			InputNums() { // 工费、料废失焦触发
				let IndustrialWaste = +this.formData.IndustrialWaste || 0;
				let MaterialWaste = +this.formData.MaterialWaste || 0;
				// 合计报废数量
				this.formData.FNgQty = IndustrialWaste + MaterialWaste;
			},
			GetPGD_GetBGType() { // 获取默认报工类型
				var that = this;
				that.$request('PGD_GetBGType', {}, function(ret) {
					if (ret.status == 200) {

						let data = ret.data.ds.map(item => {
							return {
								...item,
								JobDocTypeName: item.TypeName,
							}
						});

						that.formData = Object.assign(that.formData, data[0]);

					}
				})
			},
			getXGD_GetWorkApprove() { // 修改状态，获取是否允许审核
				var that = this;
				console.log(that.$store.state.UserInfo.UserID);
				that.$request('XGD_GetWorkApprove', {
					UserID: that.$store.state.UserInfo.UserID
				}, function(ret) {
					console.log(ret);
					if (ret.status == 200) {
						let hasApprove = ret.data.ds.some(item => {
							return item.IsWorkApprove
						})
						console.log(hasApprove);
						that.hasApprove = hasApprove;
					}
				})

			},
			GetEchoData(id) { // 获取回显的数据
				var that = this;
				that.$request('XGD_DailyOutputmxjl_2', {
					FDailyOutputDeID: id
				}, function(ret) {
					if (ret.status == 200) {
						// 定义计件计时显示值
						let PieceTimeName = that.PieceTimeNameData.find(item => item.PieceTime == ret.data.ds[0][
							'PieceTime'
						])['PieceTimeName'];
						// 定义时间显示值
						let ManHour = ret.data.ds[0]['ManHour'];
						let hour = Math.floor(ManHour); // 取整数部分作为小时数
						let minute = Math.round((ManHour - hour) * 60); // 小数部分乘以60得到分钟数
						ret.data.ds[0]['Hour'] = hour;
						ret.data.ds[0]['Minute'] = minute;


						ret.data.ds[0]['PieceTimeName'] = PieceTimeName;
						ret.data.ds[0]['JobDocTypeName'] = ret.data.ds[0]['TypeName'];
						ret.data.ds[0]['JobDocTypeID'] = ret.data.ds[0]['Define1'];
						ret.data.ds[0]['EmplName'] = ret.data.ds[0]['FProcessManName'];
						ret.data.ds[0]['EmplID'] = ret.data.ds[0]['FProcessMan'];

						ret.data.ds[0]['FPlanQty'] = ret.data.ds[0]['FPlanNum'];
						// ret.data.ds[0]['FDailyQtt'] = ret.data.ds[0]['FDailyQtt'];
						// ret.data.ds[0]['ReportQty'] = ret.data.ds[0]['ReportQty'];
						ret.data.ds[0]['ManHour'] = String(ret.data.ds[0]['ManHour']);


						that.formData = Object.assign(that.formData, ret.data.ds[0]);

						let EmplID = [];
						let EmplName = [];
						if (that.formData.EmplID) {
							console.log(typeof that.formData.EmplID);
							EmplID = String(that.formData.EmplID).split(',');
							EmplName = that.formData.EmplName.split(',');
							that.FilterFormData.EmplIDData = EmplName.map((item, index) => {
								return {
									EmplName: item,
									EmplID: +EmplID[index]
								}
							});
							that.FilterFormData.EmplIDDataJoin = that.formData.EmplName;

						}

						that.isEdit = true;
						that.getXGD_GetWorkApprove()

					} else {

						that.showMLoading = false;
						that.enabledSubmitBtn = true;
					}
				})
			},
			ChoiceTime(type) { // 点击起止时间
				var that = this;
				this.TimeType = type;
				if (type == 'start') {
					that.DatetimeData = Number(that.formData.StartTime);
					this.PickerTitle = '开始时间';
				} else if (type == 'end') {
					that.DatetimeData = Number(that.formData.EndTime);
					this.PickerTitle = '结束时间';
				} else {
					that.DatetimeData = Number(new Date());
					this.PickerTitle = '';
				}

				that.showTimePicker = true;
			},
			ClosePicker() { // 关闭时间选择器
				this.DatetimeData = Number(new Date());
				this.showTimePicker = false;
			},
			ConfirmTime(data) { // 确认时间
				var that = this;

				let currentDate = new Date();
				let currentYear = currentDate.getFullYear(); // 获取年份

				let Start = '';
				let End = '';

				if (this.TimeType == 'start') {
					// 判断是否大于结束时间
					Start = currentYear + '-' + this.dateFormat(data.value);
					End = currentYear + '-' + this.formData.EndTime;

					if (new Date(Start) > new Date(End)) {
						return uni.showToast({
							title: '开始时间不能高于结束时间',
							icon: 'none'
						})
					}

					this.formData.StartTime = this.dateFormat(data.value);
					that.$set(that.formData, 'StartTime', this.dateFormat(data.value));
				} else if (this.TimeType == 'end') {
					// 判断是否大于开始时间
					Start = currentYear + '-' + this.formData.StartTime;
					End = currentYear + '-' + this.dateFormat(data.value);

					if (new Date(Start) > new Date(End)) {
						return uni.showToast({
							title: '结束时间不能低于开始时间',
							icon: 'none'
						})
					}

					this.formData.EndTime = this.dateFormat(data.value);
					that.$set(that.formData, 'EndTime', this.dateFormat(data.value));
				}
				this.showTimePicker = false;
			},
			dateFormat(val, Type = 'MM-dd  hh:mm') { // 格式化时间
				var that = this;
				if (!that.$utils.isEmpty(val)) {
					return that.Request.dateFormat(new Date(val), Type);
				} else {
					return that.Request.dateFormat(new Date(), Type);
				}
			},
			ChangeDate() { // 报工时长输入框 input 事件
				var that = this;

				let Hour = +this.formData.Hour;
				let Minute = +(String(this.formData.Minute).replace(/\D/g, ''));

				if (Minute >= 60) {
					Hour += Math.floor(Minute / 60);
					that.$set(that.formData, 'Hour', String(Hour));

					that.$set(that.formData, 'Minute', String(1));
					setTimeout(() => {

						that.$set(that.formData, 'Minute', String(Minute % 60));
					}, 50)
				} else {
					that.$set(that.formData, 'Minute', String(Minute));
				}

				setTimeout(() => {
					let ManHour = Hour + Minute / 60;
					that.$set(that.formData, 'ManHour', String(ManHour));

					let GetDate = (+that.formData.Hour * 60 * 1000 * 60) + (+that.formData.Minute * 60 * 1000);

					if (that.$utils.isEmpty(that.formData.EndTime)) { // 如果结束时间是空的
						// 设置结束时间为当前时间
						that.formData.EndTime = that.Request.dateFormat(new Date(), 'MM-dd  hh:mm');

						let NewData = that.Request.dateFormat(Number(new Date(that.formData.EndTime)) - GetDate,
							'MM-dd  hh:mm');

						that.$set(that.formData, 'StartTime', NewData);
					} else {
						let NewData = that.Request.dateFormat(Number(new Date(that.formData.EndTime)) - GetDate,
							'MM-dd  hh:mm');

						that.$set(that.formData, 'StartTime', NewData);
					}

					that.$refs.uForm.validate();
				}, 800)
			},
			BlurDateIpt(str) { // 报工时长输入框失焦事件
				let that = this;
				switch (str) {
					case 'hour':
						that.formData.Hour = !that.$utils.isEmpty(that.formData.Hour) ? that.formData.Hour : 0;
						break;
					case 'minute':
						that.formData.Minute = !that.$utils.isEmpty(that.formData.Minute) ? that.formData.Minute : 0;
						break;
					default:
						break;
				}
			},
			OpenChoiceDate() { // 点击报工时长箭头，打开选择时间弹层
				this.showTimePickerBG = true;
				// 拼接时间，打开弹层显示对应时间
				this.DatetimeDataBG = String(this.formData.Hour) + ':' + String(this.formData.Minute);
			},
			formatter(type, data) { // 时间选择器数据格式化
				let value = +data;
				if (type === 'year') {
					return `${value}年`
				}
				if (type === 'month') {
					return `${value}月`
				}
				if (type === 'day') {
					return `${value}日`
				}
				if (type === 'hour') {
					if (value < 10) {
						value = '0' + value
					}
					return `${value}时`
				}
				if (type === 'minute') {
					if (value < 10) {
						value = '0' + value
					}
					return `${value}分`
				}
				return value
			},
			ClosePickerBG() {
				this.showTimePickerBG = false;
			},
			ConfirmTimeBG(data) { // 报工时长时间选择器确认按钮
				let that = this;
				let TheData = data.value.split(':');
				let formattedArray = TheData.map(item => parseInt(item));

				this.formData.Hour = String(formattedArray[0]);
				this.formData.Minute = String(formattedArray[1]);
				that.ChangeDate();

				that.ClosePickerBG();

			},
			/**
			 * 当获取到工单号或报工单号时，获取第一个工序
			 */
			GetProcedureData() { // 获取工序
				let that = this;
				// let ProcedureCmd = 'GD_WorkOrderProcedure'; // 工序
				// if (that.FCJType == 2) {
				// 	ProcedureCmd = 'GD_WorkOrderProcedure';
				// } else if (that.FCJType == 1) {
				// 	ProcedureCmd = 'Get_JobOrderProcedure';
				// }

				that.$request('XGD_GetAllPProceByWoOrJob', {
					WoOrderID: that.formData.WoOrderID,
					JobOrderID: that.formData.JobOrderID || 0,
				}, function(ret) {
					if (ret.status == 200) {
						if (ret.data.ds.length) {
							let ProcessData = {};
							if (that.UserWorkshopID) {
								let filterData = ret.data.ds.filter((item) => {
									return item.FWorkshopID == that.UserWorkshopID;
								})
								if (filterData.length) {
									ProcessData = filterData[0];
								} else {
									ProcessData = ret.data.ds[0];
								}
							} else {
								ProcessData = ret.data.ds[0];
							}
							ProcessData['FNgQty'] = null;
							ProcessData['FDailyQtt'] = ProcessData['ReportQty'];

							that.formData = Object.assign(that.formData, ProcessData);
							that.$refs.uForm.validate();
							/*
							ret.data.ds[0]['FNgQty'] = null;
							ret.data.ds[0]['FDailyQtt'] = ret.data.ds[0]['ReportQty'];

							that.formData = Object.assign(that.formData, ret.data.ds[0]);
							that.$refs.uForm.validate();
							*/
						}
					}
				})
			},
			GetDroplist_Shift() { // 开局默认选中班次
				let that = this;

				that.$request('Droplist_Shift', {}, function(ret) {

					if (ret.status == 200) {
						if (ret.data.ds.length) {
							that.formData = Object.assign(that.formData, ret.data.ds[0]);
							that.$refs.uForm.validate();
						}
					}
				})

			},
			openBaseScreen(str, type) { // 前往筛选页
				let that = this;

				// if (type !== 'scan' && (str !== '工单号' && str !== '派工单号')) {
				// 	const isWoBillNOEmpty = that.FCJType === 2 ? that.$utils.isEmpty(that.formData.WoBillNO) : false;
				// 	const isBillNOEmpty = that.FCJType === 1 ? that.$utils.isEmpty(that.formData.BillNO) : false;
				// 	if (isWoBillNOEmpty || isBillNOEmpty) {
				// 		const title = that.FCJType === 2 ? '请扫描工单二维码' : '请扫描派工单二维码';
				// 		uni.showToast({
				// 			title: title,
				// 			icon: 'none'
				// 		});
				// 		return;
				// 	}
				// }

				// let ProcedureCmd = 'GD_WorkOrderProcedure'; // 工序
				// let SelectKey = 'WoPROCID';
				// if (that.FCJType == 2) {
				// 	ProcedureCmd = 'GD_WorkOrderProcedure';
				// 	SelectKey = 'WoPROCID';
				// } else if (that.FCJType == 1) {
				// 	ProcedureCmd = 'Get_JobOrderProcedure';
				// 	SelectKey = 'JobPROCID';
				// }


				if (type == 'radio') {
					let obj = null;
					let url = '/commonPage/Tool/baseScreen';

					if (str == '工单号' || str == '派工单号') {
						let cmd = 'XGD_BGWorkOrder'; // 工单
						if (str == '派工单号') {
							cmd = 'XGD_BGJobOrder'; // 派工单
						}
						console.log(this.formData);

						obj = {
							allowClear: false,
							cmd: cmd,
							type: str,
							ListeningName: 'CreateWorks_Choice',
							// multiple: false,
							serverSearch: {
								isPaging: true, //是否分页
								searchKey: 'BillNO', //搜索关键词，应包含在param中
								showText: str == '工单号' ? 'WoBillNO' : 'JobBillNO', //查询结果显示的字段
								pageIndexStr: 'Pageindex', //分页页码字段，应包含在param中
								subText: [{
									label: '',
									labelKey: 'ProductCode'
								}],
								ChoiceDataKey: str == '工单号' ? 'WoBillNO' : 'JobOrderID',
								ChoiceDataData: str == '工单号' ? this.formData.WoBillNO : this.formData.JobOrderID,
							},
							param: {
								BillNO: '',
								FCJType: that.FCJType,
								Pageindex: 1,
								PageSize: 30
							}
						}
					} else if (str == '报工类型') {
						if (!that.$utils.isEmpty(that.formData.BGBillNo)) return;

						obj = {
							allowClear: false,
							cmd: 'PGD_GetBGType',
							type: str,
							ListeningName: 'CreateWorks_Choice',
							// multiple: false,
							serverSearch: {
								isPaging: false, //是否分页
								// searchKey: '', //搜索关键词，应包含在param中
								showText: 'TypeName', //查询结果显示的字段
								// pageIndexStr: 'pageIndex', //分页页码字段，应包含在param中
								// subText: [{
								// 	label: '描述',
								// 	labelKey: 'desc'
								// }],
								ChoiceDataKey: 'JobDocTypeID',
								ChoiceDataData: this.formData.JobDocTypeID,
							},
							param: {}
						}
					} else if (str == '生产车间') {
						obj = {
							allowClear: false,
							cmd: 'XGD_Workshop',
							type: str,
							ListeningName: 'CreateWorks_Choice',
							// multiple: false,
							serverSearch: {
								isPaging: true, //是否分页
								searchKey: 'SearchKey', //搜索关键词，应包含在param中
								showText: 'FWorkshopName', //查询结果显示的字段
								pageIndexStr: 'PageIndex', //分页页码字段，应包含在param中
								// subText: [{
								// 	label: '描述',
								// 	labelKey: 'desc'
								// }],
								ChoiceDataKey: 'FWorkshopID',
								ChoiceDataData: this.formData.FWorkshopID,
							},
							param: {
								SearchKey: '',
								PageIndex: 1,
								PageSize: 30
							}
						}
					} else if (str == '工序') {

						if (that.$utils.isEmpty(that.formData.FWorkshopID)) {
							return uni.showToast({
								title: '请选择生产车间',
								icon: 'none'
							});
						};

						console.log(this.formData)

						obj = {
							allowClear: false,
							cmd: 'XGD_GetAllPProceByWoOrJob',
							type: str,
							ListeningName: 'CreateWorks_Choice',
							// multiple: false,
							serverSearch: {
								isPaging: false, //是否分页
								// searchKey: '', //搜索关键词，应包含在param中
								showText: 'ProcedureName', //查询结果显示的字段
								// pageIndexStr: 'pageIndex', //分页页码字段，应包含在param中
								subText: [{
									label: '派工单号：',
									labelKey: 'JobBillNO'
								}, {
									label: '工单号：',
									labelKey: 'WoBillNO'
								}, {
									label: '产品：',
									labelKey: 'ProductName'
								}, {
									label: '可报数量：',
									labelKey: 'ReportQty'
								}, ],
								// ChoiceDataKey: SelectKey,
								// ChoiceDataData: this.formData[SelectKey],
							},
							param: {
								WoOrderID: that.formData.WoOrderID,
								JobOrderID: that.formData.JobOrderID,
							}
						}
					} else if (str == '模具编号') {

						if (that.$utils.isEmpty(that.formData.ProcedureID)) {
							return uni.showToast({
								title: '请选择工序',
								icon: 'none'
							});
						};
						// obj = {
						// 	allowClear: false,
						// 	cmd: 'MJ_MoludList',
						// 	type: str,
						// 	ListeningName: 'st_mold_Choice',
						// 	serverSearch: {
						// 		isPaging: false, //是否分页
						// 		searchKey: 'MoludSelect', //搜索关键词，应包含在param中
						// 		showText: 'MoludSelect', //查询结果显示的字段
						// 		pageIndexStr: 'PageIndex', //分页页码字段，应包含在param中
						// 		// ChoiceDataKey: 'MoludName',
						// 		// ChoiceDataData: that.baseFormData.MoludName,
						// 	},
						// 	param: {
						// 		FType: that.WorkbenchesTitle == '领用' ? 'LY' : 'GH',
						// 		IsInStorage: that.WorkbenchesTitle == '领用' ? 1 : 0,
						// 		MoludSelect: '',
						// 		PageIndex: 1,
						// 		PageSize: 30
						// 	}
						// }

						obj = {
							allowClear: false,
							cmd: 'PGD_GetMolud',
							type: str,
							ListeningName: 'CreateWorks_Choice',
							// multiple: false,
							serverSearch: {
								isPaging: true, //是否分页
								searchKey: 'MoludCode', //搜索关键词，应包含在param中
								showText: 'MoludCode', //查询结果显示的字段
								pageIndexStr: 'PageIndex', //分页页码字段，应包含在param中
								// subText: [{
								// 	label: '描述',
								// 	labelKey: 'desc'
								// }],
								ChoiceDataKey: 'MoludID',
								ChoiceDataData: this.formData.MoludID,
							},
							param: {
								MoludCode: '', // 筛选条件

								MoludID: 0, // 模具ID 

								IsInStorage: 0,
								PageIndex: 1,
								PageSize: 30
							}
						}
					} else if (str == '设备') {
						if (that.$utils.isEmpty(that.formData.ProcedureID)) {
							return uni.showToast({
								title: '请选择工序',
								icon: 'none'
							});
						};

						obj = {
							allowClear: false,
							cmd: 'PGD_GetEquipment',
							type: str,
							ListeningName: 'CreateWorks_Choice',
							// multiple: false,
							serverSearch: {
								isPaging: false, //是否分页
								searchKey: 'EquipmentCode', //搜索关键词，应包含在param中
								showText: 'EquipmentCode', //查询结果显示的字段
								// pageIndexStr: 'pageIndex', //分页页码字段，应包含在param中
								// subText: [{
								// 	label: '描述',
								// 	labelKey: 'desc'
								// }],
								ChoiceDataKey: 'EquipmentID',
								ChoiceDataData: this.formData.EquipmentID,
							},
							param: {
								EquipmentTypeID: this.formData.EquipmentTypeID || 0, // 类型ID
								EquipmentCode: '', // 筛选条件
								EquipmentID: this.formData.EquipmentID || 0, // 设备ID
							}
						}
					} else if (str == '班次') {
						obj = {
							allowClear: false,
							cmd: 'Droplist_Shift',
							type: str,
							ListeningName: 'CreateWorks_Choice',
							// multiple: false,
							serverSearch: {
								isPaging: false, //是否分页
								searchKey: '', //搜索关键词，应包含在param中
								showText: 'ShiftName', //查询结果显示的字段
								// pageIndexStr: 'pageIndex', //分页页码字段，应包含在param中
								// subText: [{
								// 	label: '描述',
								// 	labelKey: 'desc'
								// }],
								ChoiceDataKey: 'ShiftID',
								ChoiceDataData: this.formData.ShiftID,
							},
							param: {}
						}
					} else if (str == '作业员') {
						obj = {
							allowClear: false,
							cmd: 'XGD_Employee',
							type: str,
							ListeningName: 'CreateWorks_Choice',
							// multiple: false,
							serverSearch: {
								isPaging: true, //是否分页
								searchKey: 'EmplCode', //搜索关键词，应包含在param中
								showText: 'EmplName', //查询结果显示的字段
								pageIndexStr: 'Pageindex', //分页页码字段，应包含在param中
								// subText: [{
								// 	label: '描述',
								// 	labelKey: 'desc'
								// }],
								ChoiceDataKey: 'EmplID',
								ChoiceDataData: this.formData.EmplID,
							},
							// IsAllowAddEdit: '作业员', // 是否允许新增编辑
							param: {
								EmplCode: '',
								Pageindex: 1,
								PageSize: 30,
								FWorkshopID: this.formData.FWorkshopID || 0
							}
						}
					} else if (str == '计时计件') {

						obj = {
							allowClear: false,
							cmd: '',
							type: str,
							ListeningName: 'CreateWorks_Choice',
							// multiple: false,
							serverSearch: {
								isPaging: true, //是否分页
								searchKey: '', //搜索关键词，应包含在param中
								showText: 'PieceTimeName', //查询结果显示的字段
								// pageIndexStr: 'pageIndex', //分页页码字段，应包含在param中
								// subText: [{
								// 	label: '描述',
								// 	labelKey: 'desc'
								// }],
								ChoiceDataKey: 'PieceTime',
								ChoiceDataData: this.formData.PieceTime,
							},
							param: {
								data: JSON.parse(JSON.stringify(this.PieceTimeNameData))
							}
						};

						url = '/commonPage/Tool/baseScreen?select=1';
					}

					this.$store.commit('ChangeAndSetStateData', {
						Name1: 'BaseScreenParm',
						data: obj
					})

					uni.navigateTo({
						url: url
					})

				} else if (type == 'check') {
					let obj = null;
					let url = '/commonPage/Tool/SelectBaseScreen';

					if (str == '作业员') {

						obj = {
							allowClear: false,
							cmd: 'XGD_Employee',
							type: str,
							ListeningName: 'CreateWorks_Choice',
							// multiple: false,
							serverSearch: {
								isPaging: true, //是否分页
								searchKey: 'EmplCode', //搜索关键词，应包含在param中
								showText: 'EmplName', //查询结果显示的字段
								pageIndexStr: 'Pageindex', //分页页码字段，应包含在param中

								ChoiceDataKey: 'EmplID',
								ChoiceDataData: this.FilterFormData.EmplIDData
							},

							param: {
								EmplCode: '',
								Pageindex: 1,
								PageSize: 30,
								FWorkshopID: this.formData.FWorkshopID || 0
							}
						}

					}

					this.$store.commit('ChangeAndSetStateData', {
						Name1: 'BaseScreenParm',
						data: obj
					})

					uni.navigateTo({
						url: url
					})
				} else if (type == 'scan') {

					const type = 'CAMERA' // 权限名称，其他权限看下面文档
					this.$refs.permissionDialog.requestPermission(type).then(() => {
						// 完成授权流程，开始业务代码

						that.$scanPopup.openScan({
							success: (res) => {
								that.getMainInfo(res.result);
							}
						})

					})

				}

			},
			OpenScanBtn() { // 扫码按钮
				let that = this;
				this.$scanPopup.openScan({
					success: (res) => {
						console.log(res);

						function startsWithEQRegex(str) {
							return /^EQ/.test(str) || /^SB/.test(str);
						}

						// 判断扫描的二维码是否为设备二维码
						let IsDevice = startsWithEQRegex(res.result)
						if (IsDevice) {
							// 如果是设备二维码，获取该设备的派工单数据
							that.DeviceID = res.result;
							that.getMainInfoByDevice();
						} else {
							that.getMainInfo(res.result);
						}
					}
				})

			},
			closeDevicePopup() { // 关闭设备工序弹层
				this.showPopupByDevice = false;
				this.ScanByDeviceList = [];
				this.SelectScanByDeviseIndex = null;
			},
			ChoiceProcedure_Config() {
				if (!this.$utils.isEmpty(this.SelectScanByDeviseIndex)) {
					// console.log(this.ScanByDeviceList[this.SelectScanByDeviseIndex])
					let data = this.ScanByDeviceList[this.SelectScanByDeviseIndex];

					data['ReportQty'] = data['ReportQty'];
					// 获取选中项数据
					this.formData = Object.assign(this.formData, data);

					this.$refs.uForm.validate();
					this.closeDevicePopup();
				} else {
					this.$utils.msg('请选中一项数据！', 1000)
				}
			},
			ChoiceDeviceToProcedure(index) { // 点击设备工序弹层列表的某一项

				// 首先取消所有项的选中状态  
				this.ScanByDeviceList.forEach(item => (item.checked = false));

				// 然后将点击的项设置为选中状态  
				this.ScanByDeviceList[index].checked = true;

				this.SelectScanByDeviseIndex = index;

			},
			getMainInfoByDevice() { // 扫码获取设备数据
				let that = this;
				let parts = that.DeviceID.split("|");

				that.$utils.showLoading();

				try {
					// 扫设备带出可报工工序
					// console.log(that.DeviceID)

					that.$request('XGD_GetPROCByEquipment_2', {
						EquipmentID: parts[1],
						QrCode: that.DeviceID,
						FCJType: that.FCJType
					}, ret => {
						console.log(ret)
						that.ScanByDeviceList = [];
						if (ret.status == 200) {
							this.showPopupByDevice = true;

							if (ret.data.ds.length && ret.data.ds[0].status != 500) {
								setTimeout(() => {

									let data = ret.data.ds.map(item => {
										return {
											...item,
											checked: false,
											BillNO: item.JobBillNO
										}
									});
									that.$refs.paging.complete(data);
									that.$utils.hideLoading();
								}, 500);
							} else {

								that.$refs.paging.complete([]);
								that.$utils.hideLoading();
							}

						}
					}, err => {
						that.$refs.paging.complete([]);
						that.$utils.hideLoading();
						console.log(err)
					})

				} catch (e) {
					//TODO handle the exception
					that.$refs.paging.complete([]);
					that.$utils.hideLoading();
				}
			},
			getMainInfo(val) { // 扫码获取各类二维码信息
				let that = this;
				let parts = val.split("|");


				if (parts[0] == 'PGD') {
					if (that.FCJType != 1) {
						return that.$utils.msg('请扫描工单二维码')
					};
					// 派工单号
					that.$request('Get_JobOrder', {
						QrCode: val
					}, function(ret) {
						console.log(ret)
						if (ret.status == 200 && ret.data.ds.length && ret.data.ds[0].status != 500) {

							that.InitCreateFun();
							setTimeout(() => {
								that.formData.QrCode = val;
								that.formData = Object.assign(that
									.formData, ret.data.ds[0]);

								// 当前以选中 派工单号，获取工序
								that.GetProcedureData();

								that.$utils.hideLoading(500);

								that.$refs.uForm.validate();
							}, 300)
						} else if (ret.data.ds[0].status == 500) {
							that.$utils.msg(ret.data.ds[0].msg)
						}
					})

				} else if (parts[0] == 'GD') {
					if (that.FCJType == 1) {
						return that.$utils.msg('请扫描派工单二维码')
					};
					// 工单号
					that.$request('GD_WorkOrder', {
						QrCode: val
					}, function(ret) {
						console.log(ret)
						if (ret.data.ds[0].status == 500) {
							that.$utils.msg(ret.data.ds[0].msg)
						} else {
							that.formData.QrCode = val;
							ret.data.ds[0]['QrCode'] = val;

							that.formData = Object.assign(that
								.formData, ret.data.ds[0]);

							// 当前以选中工单号 ，获取工序
							that.GetProcedureData();

							that.$refs.uForm.validate();
							that.$utils.hideLoading(500);
						}
					});

				} else {


					// 模具
					let da2 = that.Request.PromiseRequest('PGD_GetMolud', {
						// MoludCode: val, // 筛选条件
						MoludID: parts[1], // 模具ID					
						IsInStorage: 0,
						PageIndex: 1,
						PageSize: 30
					});

					// 设备
					let da3 = that.Request.PromiseRequest('PGD_GetEquipment', {
						EquipmentTypeID: this.formData.EquipmentTypeID || 0, // 类型ID
						EquipmentCode: val, // 筛选条件
						EquipmentID: this.formData.EquipmentID || 0, // 设备ID
					});


					da2.promise.then((data) => { // 模具

						if (that.$utils.isEmpty(that.formData.ProcedureID)) {
							that.$utils.hideLoading();
							uni.showToast({
								title: '请选择工序',
								icon: 'none'
							});
							throw new Error('请选择工序');
						};
						console.log(data)
						if (data.data.ds.length > 0 && data.data.ds[0].status == 500) {
							return da3.promise
						} else {
							that.$utils.hideLoading(500);
							if (data.data.ds.length > 0) {
								that.formData = Object.assign(that.formData, data.data.ds[0]);
								that.$utils.hideLoading(500);
							} else {
								that.$utils.hideLoading();
								uni.showToast({
									title: data.data.ds1[0].MSG,
									icon: 'none'
								})
							}
							throw new Error('终止条件满足');
						}
					}).then((result) => { // 设备
						da2 = null;
						if (that.$utils.isEmpty(that.formData.ProcedureID)) {
							that.$utils.hideLoading();
							uni.showToast({
								title: '请选择工序',
								icon: 'none'
							});
							throw new Error('请选择工序');
						};
						// console.log(result)
						if (result.data.ds.length && result.data.ds[0].status == 500) {
							that.$utils.hideLoading();
							uni.showToast({
								title: '请扫描正确的二维码'
							})
						} else {
							// console.log(result)

							if (result.data.length) {
								that.formData = Object.assign(that.formData, result.data);
								that.$utils.hideLoading(500);
							} else {
								that.$utils.hideLoading();
								uni.showToast({
									title: '请扫描正确的二维码',
									icon: 'none'
								})
							}

							throw new Error('终止条件满足');
						}
					}).catch((err) => {
						// console.log(err)
						that.$utils.hideLoading();
						if (err.status == 500) {
							uni.showToast({
								title: '请扫描正确的二维码',
								icon: 'none'
							})
						}
					})
				}


			},
			afterRead() {

			},
			deletePic() {

			},
			WorkInit() { // 工单页面初始化（继续报工）

				this.ShowContinuePopup = true;
			},
			selectClick(data) {
				let that = this;

				// console.log(data)

				let cloneObj = this.$utils.deepClone(that.formData)
				// console.log(cloneObj)
				// return
				let ReservedFields = ['JobDocTypeName', 'JobDocTypeID'];

				that.isEdit = false; // 将状态却换成非编辑状态
				that.hasApprove = false; // 关闭审核

				// 连续报工,且未审核
				if (data.id == 1) {
					// 如果是非审核状态，保留作业员字段
					// ReservedFields = ['EmplID', 'EmplName', 'PieceTime', 'PieceTimeName',
					// 	'ShiftID', 'ShiftName', 'JobDocTypeName', 'JobDocTypeID'
					// ];
					ReservedFields = ['FDailyQtt', 'FNgQty', 'FDailyOutputDeID', 'BGBillNo', 'BillNo']
				}

				Object.keys(that.formData).forEach((key) => {

					let arrayType = null;
					if (data.id == 1) {
						arrayType = ReservedFields.includes(key)
					} else if (data.id == 0) {

						arrayType = !ReservedFields.includes(key)
					}

					// if (!ReservedFields.includes(key)) {
					if (arrayType) {


						if (that.formData[key] == null) {
							that.formData[key] = null;
						} else if (Array.isArray(that.formData[key])) {
							that.formData[key] = [];
						} else if (typeof that.formData[key] === 'object') {
							that.formData[key] = {};
						} else {
							that.formData[key] = '';
						}
					}
				});
				if (data.id == 0) {
					this.InitFormData();
				}
				// if (data.id == 1) {
				// 	let BillNO = cloneObj.BillNO;
				// 	// 继续报工
				// 	// 调一遍获取 工单、派工单 接口
				// 	let cmd = 'XGD_BGWorkOrder'
				// 	if (that.FCJType == 1) {
				// 		cmd = 'XGD_BGJobOrder'
				// 	} else {
				// 		BillNO = cloneObj.WoBillNO
				// 	}
				// 	console.log(BillNO)

				// 	that.$request(cmd, {
				// 		BillNO: BillNO,
				// 		FCJType: that.FCJType,
				// 		Pageindex: 1,
				// 		PageSize: 30
				// 	}, (ret) => {
				// 		if (ret.status == 200) {
				// 			if (ret.data.ds.length) {
				// 				console.log(ret)

				// 				let backData = that.$utils.deepClone(ret.data.ds[0])
				// 				console.log(backData)
				// 				backData['BillNO'] = backData['JobBillNO'];

				// 				Object.assign(that.formData, backData)
				// 			}
				// 		}
				// 	})
				// }
			},
			closeContinuePopup() {
				this.ShowContinuePopup = false;
			},
			SubmitBtn(Type = 'Submit') { // 提交按钮
				let that = this;

				if (!this.enabledSubmitBtn) {
					return;
				}

				this.showMLoading = true;
				this.loadingText = "正在验证字段";
				this.enabledSubmitBtn = false;

				this.$refs.uForm.validate().then(res => {

					that.loadingText = "验证成功，准备提交";
					// return

					let ManHour = +that.formData.Hour + +that.formData.Minute / 60;

					let obj = {

						Define1: this.formData.JobDocTypeID, // 单据类型

						SoOrderID: this.formData.SoOrderID || 0, // 销售订单主表ID
						SoOrderDeID: this.formData.SoOrderDeID, // 销售订单子表ID
						ProductID: this.formData.ProductID, // 产品ID

						FWorkshopID: this.formData.FWorkshopID, // 生产车间
						ProcedureID: this.formData.ProcedureID, // 工序ID

						PieceTime: this.formData.PieceTime, // 计时计件

						FProcessMan: this.formData.EmplID, // 作业员ID
						ShiftID: this.formData.ShiftID, // 班次

						FDailyQtt: +this.formData.FDailyQtt || 0, // 合格数量
						IndustrialWaste: this.formData.IndustrialWaste || 0, // 工费数
						MaterialWaste: this.formData.MaterialWaste || 0, // 料废数
						FNgQty: +this.formData.FNgQty || 0, // 不良数量

						SCDate: this.dateFormat(new Date(), 'Y-MM-dd hh:mm:ss'), // 生产日期
						WoOrderID: this.formData.WoOrderID, // 工单ID


						FCJType: that.FCJType, // 单据类别
						ManHour: ManHour, // 工时
						EquipmentID: this.formData.EquipmentID || 0, // 设备ID
						MoludID: this.formData.MoludID || 0, // 模具ID
						FRemarks: this.formData.FRemarks, // 子表备注

						JobOrderID: this.formData.JobOrderID, // 派工单ID
						JobPROCID: this.formData.JobPROCID, // 派工单子表ID
						WoPROCID: this.formData.WoPROCID, // 工单工序

						JobPROCAssignEQID: this.formData.JobPROCAssignEQID || 0, // 派工单指定ID
						WoPROCAssignEQID: this.formData.WoPROCAssignEQID || 0, // 派工单指定ID
					};

					// console.log(obj)

					that.loadingText = "正在提交";
					that.$request('XGD_DailyOutputBG_2', obj, function(ret) {
						console.log(ret)
						if (ret.data.ds[0].status == 500) {
							// uni.showToast({
							// 	title: ret.data.ds[0].msg,
							// 	icon: 'none'
							// })
							that.loadingText = "提交失败";
							layer.alert(ret.data.ds[0].msg)
							// that.enabledSubmitBtn = true;
						} else {
							// uni.showToast({
							// 	title: ret.data.ds[0].msg,
							// 	icon: 'success'
							// });

							that.loadingText = "提交成功";

							// 调用回显接口，处于修改状态
							that.formData.FDailyOutputDeID = ret.data.ds[0].FDailyOutputDeID;
							that.GetEchoData(ret.data.ds[0].FDailyOutputDeID);

							// 刷新报工列表
							uni.$emit('Refresh', {
								refresh: true
							})

						}
					}, function(err) {
						console.log(err)
						that.showMLoading = false;
						that.enabledSubmitBtn = true;
					})

				}).catch(errors => {
					console.log(JSON.stringify(errors))
					if (Array.isArray(errors)) {
						// that.showLoading = false;
						uni.$u.toast('请完善表单')
					}
					that.showMLoading = false;
					that.enabledSubmitBtn = true;
				});
			},
			EditBtn(Type) { // 修改按钮
				let that = this;
				if (!this.enabledSubmitBtn) {
					return;
				}

				this.showMLoading = true;
				this.enabledSubmitBtn = false;

				this.loadingText = "正在验证字段";
				this.$refs.uForm.validate().then(res => {
					that.loadingText = "验证成功，准备提交";

					if (that.formData.Approve) {
						that.ApproveBtn();
						return
					}

					let ManHour = +this.formData.Hour + +this.formData.Minute / 60;

					let obj = {
						FDailyOutputID: this.formData.FDailyOutputID || 0, // 主表ID
						FDailyOutputDeID: this.formData.FDailyOutputDeID || 0, // 子表ID

						Define1: this.formData.JobDocTypeID, // 单据类型

						SoOrderID: this.formData.SoOrderID || 0, // 销售订单主表ID
						SoOrderDeID: this.formData.SoOrderDeID || 0, // 销售订单子表ID
						ProductID: this.formData.ProductID, // 产品ID

						FWorkshopID: this.formData.FWorkshopID, // 生产车间
						ProcedureID: this.formData.ProcedureID, // 工序ID

						PieceTime: this.formData.PieceTime, // 计时计件

						FProcessMan: this.formData.EmplID, // 作业员ID
						ShiftID: this.formData.ShiftID, // 班次

						FDailyQtt: +this.formData.FDailyQtt || 0, // 合格数量
						IndustrialWaste: this.formData.IndustrialWaste || 0, // 工费数
						MaterialWaste: this.formData.MaterialWaste || 0, // 料废数
						FNgQty: +this.formData.FNgQty || 0, // 不良数量

						SCDate: this.dateFormat(new Date(), 'Y-MM-dd hh:mm:ss'), // 生产日期
						WoOrderID: this.formData.WoOrderID, // 工单ID


						FCJType: that.FCJType, // 单据类别
						ManHour: ManHour, // 工时
						EquipmentID: this.formData.EquipmentID, // 设备ID
						MoludID: this.formData.MoludID, // 模具ID
						FRemarks: this.formData.FRemarks, // 子表备注
					};

					// let submitCmd = 'GD_DailyOutputUpdate';
					if (that.FCJType == 1) {

						obj['JobOrderID'] = this.formData.JobOrderID || 0; // 派工单ID
						obj['JobPROCID'] = this.formData.JobPROCID || 0; // 派工单子表ID

						obj['WoPROCAssignEQID'] = this.formData.WoPROCAssignEQID;
						obj['JobPROCAssignEQID'] = this.formData.JobPROCAssignEQID;
						obj['WoPROCID'] = this.formData.WoPROCID || 0; // 工单工序

						// submitCmd = 'XGD_DailyOutputUpdate_2';
					} else if (that.FCJType == 2) {

						obj['WoPROCID'] = this.formData.WoPROCID || 0; // 工单工序

						// submitCmd = 'GD_DailyOutputUpdate';
					}

					that.loadingText = "正在提交";
					that.$request('XGD_DailyOutputUpdate_2', obj, function(ret) {

						if (ret.data.ds[0].status == 500) {
							uni.showToast({
								title: ret.data.ds[0].msg,
								icon: 'none'
							})
							that.loadingText = "提交失败";
							that.showMLoading = false;
							that.enabledSubmitBtn = true;
						} else {
							if (Type == 'Audit') {
								that.ApproveBtn();

							} else {

								// uni.showToast({
								// 	title: ret.data.ds[0].msg,
								// 	icon: 'success'
								// });
								that.loadingText = "提交成功";

								// 调用回显接口，处于修改状态
								that.formData.FDailyOutputDeID = ret.data.ds[0].FDailyOutputDeID;
								that.GetEchoData(ret.data.ds[0].FDailyOutputDeID);

								// 刷新报工列表
								uni.$emit('Refresh', {
									refresh: true
								})
							}

						}
					})

				}).catch(errors => {
					console.log(JSON.stringify(errors))
					if (Array.isArray(errors)) {
						// that.showLoading = false;
						uni.$u.toast('请完善表单')
					}
					that.showMLoading = false;
					that.enabledSubmitBtn = true;
				});
			},
			ApproveBtn() { // 审核、撤审按钮
				let that = this;

				let obj = {
					KeyID: this.formData.FDailyOutputID,
					Type: this.formData.Approve ? -1 : 1,
					UserName: this.$store.state.UserInfo.UserName,
					FCJType: that.FCJType
				};
				// let submitCmd = (that.FCJType == 1) ? 'XGD_ApproveSub' : 'GD_ApproveSub';

				that.loadingText = this.formData.Approve ? "正在撤审" : "正在审核";
				this.$request('XGD_ApproveSubByFCJType', obj, function(ret) {
					console.log(ret);
					if (ret.data.ds[0].status == 500) {

						// uni.showToast({
						// 	title: ret.data.ds[0].msg,
						// 	icon: 'none'
						// })
						that.loadingText = that.formData.Approve ? "撤审失败" : "审核失败";
						layer.alert(ret.data.ds[0].msg);
						that.showMLoading = false;
						that.enabledSubmitBtn = true;
					} else {

						if (ret.data.ds[0]['RZT'] == 500) {
							// that.$utils.msg(ret.data.ds[0]['RMS'])
							layer.alert(ret.data.ds[0]['RMS'])
							that.enabledSubmitBtn = true;
							that.showMLoading = false;
						} else {

							// 刷新报工列表
							uni.$emit('Refresh', {
								refresh: true
							})

							// uni.showToast({
							// 	title: that.formData.Approve ? '撤审成功' : '审核成功'
							// })

							that.loadingText = that.formData.Approve ? '撤审成功' : '审核成功';
							that.GetEchoData(that.formData.FDailyOutputDeID);
						}
					}
				})

			}
		},
	}
</script>

<style lang="scss">
	.flex-auto {
		flex: 1;
		overflow: auto;
		height: 100%;
	}

	.content {
		display: flex;
		flex-direction: column;
		height: 100vh;
		// height: calc(100vh - 60px);
		background-color: #f9f9f9;

		uni-button {
			margin-left: initial !important;
			margin-right: initial !important;
		}

		.MainPopup {
			flex: initial !important;
		}

		.content_main {
			flex: 1;
			// overflow: auto;
			// padding: 10px;

			// 表单1
			.u-form {
				// padding: 0px 10px;
				padding-bottom: 20px;

				.u-form-item {
					background-color: #fff;
					padding: 0 6px 0 12px;

					.u-form-item__body {
						padding: 8px 0 !important;

						.uni-input-placeholder {
							font-size: 12px;
						}
					}

					.TabsBox {
						padding: 0px 15px;
						background-color: #fff;

						.u-tabs__wrapper__nav__item__text {
							padding: 4px 10px !important;
							min-width: 80px;
							text-align: center;
							font-weight: 600;
							border-radius: 15px;
						}
					}


				}

				.PriceItem {

					.u-form-item__body__left__content__label {
						font-size: 12px !important;
					}
				}

				.TopOption {

					.u-form-item__body {
						flex-direction: column !important;
					}
				}

				// 起止时间
				.ChoiceTimesBox {
					width: 100%;
					display: flex;
					align-items: center;
					// background-color: #fff;
					// padding: 18px 10px;
					// margin-top: 10px;

					.TimeBox {
						flex: 1;
						display: flex;
						align-items: center;
						justify-content: space-evenly;

						.timer {
							width: 100%;
							flex: 2;
							display: flex;
							flex-direction: column;
							// align-items: center;
							font-size: 16px;
							color: #333;

							text:first-child {
								margin-bottom: 10px;
								font-weight: 600;
							}

							text:last-child {
								height: 20px;
								font-size: 14px;
							}
						}

						.Icon {
							flex: 1;
						}
					}
				}


				// 上传-删除图标
				.u-upload__deletable {
					width: 20px;
					height: 20px;

					.u-upload__deletable__icon {
						right: -1px !important;

						.u-icon__icon {
							font-size: 20px !important;
							line-height: 16px !important;
						}
					}
				}
			}
		}

		.content_bottom {
			background-color: #fff;

			uni-button {
				font-size: 26rpx !important;
				margin-left: 8rpx !important;
			}
		}

		.BottomBox {
			uni-button {
				margin-right: 10px !important;
			}
		}
	}

	// 复选框样式 start
	.uni-checkbox-input {
		border: 2px solid #d1d1d1 !important;
		border-radius: 9999px !important;
	}

	.uni-checkbox-input-checked {
		background: #51d0d0;
		color: #fff !important;
		border-color: #51d0d0 !important;
	}

	// 复选框样式 End

	.inputClass {
		/* opacity: 0; */
		width: 150px;
	}

	.scanLine {
		position: absolute;
		z-index: 2;
		width: 66%;
		height: 2px;
		transform: translateX(25%);
		background-color: #51d0d0;
		animation: scanLineMove 2s infinite;
	}

	.newClass {
		color: red;
	}

	@keyframes scanLineMove {
		from {
			top: 30px;
		}

		to {
			top: 120px;
		}
	}

	.IptStyle {
		opacity: 1;
		position: absolute;
		top: 0;
		left: 0;
	}
</style>